package com.platform.module.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.core.text.Convert;
import com.platform.module.domain.LinkSubMeter;
import com.platform.module.mapper.LinkSubMeterMapper;
import com.platform.module.service.ILinkSubMeterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 地址和热表关联Service业务层处理
 * 
 * @author wangqi
 * @date 2020-08-01
 */
@Service
public class LinkSubMeterServiceImpl extends ServiceImpl<LinkSubMeterMapper,LinkSubMeter> implements ILinkSubMeterService
{
    @Autowired
    private LinkSubMeterMapper linkSubMeterMapper;

    /**
     * 查询地址和热表关联列表
     * 
     * @param linkSubMeter 地址和热表关联
     * @return 地址和热表关联
     */
    @Override
    public List<LinkSubMeter> selectLinkSubMeterList(LinkSubMeter linkSubMeter)
    {
        return linkSubMeterMapper.selectLinkSubMeterList(linkSubMeter);
    }

    /**
     * 新增地址和热表关联
     * 
     * @param linkSubMeter 地址和热表关联
     * @return 结果
     */
    @Override
    public int insertLinkSubMeter(LinkSubMeter linkSubMeter)
    {
        return linkSubMeterMapper.insert(linkSubMeter);
    }

    /**
     * 修改地址和热表关联
     * 
     * @param linkSubMeter 地址和热表关联
     * @return 结果
     */
    @Override
    public int updateLinkSubMeter(LinkSubMeter linkSubMeter)
    {
        linkSubMeterMapper.delete(new QueryWrapper<LinkSubMeter>().eq("calorimeter_id", linkSubMeter.getCalorimeterId()));
        return linkSubMeterMapper.insert(linkSubMeter);
    }

    /**
     * 删除地址和热表关联对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLinkSubMeterByIds(String ids)
    {
        return linkSubMeterMapper.deleteBatchIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除地址和热表关联信息
     * 
     * @param calorimeterId 地址和热表关联ID
     * @return 结果
     */
    @Override
    public int deleteLinkSubMeterById(String calorimeterId)
    {
        return linkSubMeterMapper.deleteById(calorimeterId);
    }
}
